1 <?php
2     
3     session_start();
4     require
"includes/db.php";
5     require
"includes/functions.php";
6     
if(isset($_SESSION['user'])) {
7         header(
"location: food_list.php");
8     }
9     
10     
if($_SERVER['REQUEST_METHOD'] == 'POST') {
11         
12         
if(isset($_POST['submit'])) {
13             
14             $user = escape($_POST[
'username']);
15             $pass = md5($_POST[
'password']);
16             
17             
if($user != "" && $pass != "") {
18                 
19                 
//$verify = $db->query("SELECT * FROM admin WHERE username='$user' AND password='$pass' LIMIT 1");
20                 $verify = $db->query(
"SELECT * FROM admin WHERE username='$user' LIMIT 1");
21                 
22                 
if($verify->num_rows) {
23                     
24                     $row = $verify->fetch_assoc();
25                     
26                     $_SESSION[
'user'] = $row['username'];
27                     header(
"location: food_list.php");
28                     
29                     
//echo "LOGGED IN";
30                     
31                 }
else{
32                     
33                     echo
"<script>alert('Invalid login credentials. Please try again')</script>";
34                     
35                 }
36                 
37             }
else{
38                 
39                 echo
"<script>alert('Some fields are empty. All fields required!')</script>";
40                 
41             }
42             
43         }
44         
45     }
46     
47 ?>
48
49 <!doctype html>
50 <html lang=
"en">
51 <head>
52     <meta charset=
"utf-8" />
53     <link rel=
"icon" type="image/png" href="assets/img/favicon.ico">
54     <meta http-equiv=
"X-UA-Compatible" content="IE=edge,chrome=1" />
55
56     <title>Unique Restaurant</title>
57
58     <meta content=
'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
59     <meta name=
"viewport" content="width=device-width" />
60
61
62     <!-- Bootstrap core CSS -->
63     <link href=
"assets/css/bootstrap.min.css" rel="stylesheet" />
64
65     <!-- Animation library
for notifications -->
66     <link href=
"assets/css/animate.min.css" rel="stylesheet"/>
67
68     <!-- Light Bootstrap Table core CSS -->
69     <link href=
"assets/css/light-bootstrap-dashboard.css" rel="stylesheet"/>
70
71
72     <!-- CSS
for Demo Purpose, don't include it in your project -->
73     <link href=
"assets/css/demo.css" rel="stylesheet" />
74
75
76     <!-- Fonts and icons -->
77     <link href=
"assets/css/pe-icon-7-stroke.css" rel="stylesheet" />
78     
79     <link href=
"assets/css/style.css" rel="stylesheet" />
80     
81 </head>
82 <body>
83
84 <div
class="login_wrapper">
85     
86     <div
class="login_holder">
87             
88         <form method=
"post" action="index.php">
89             
90             <div
class="header">
91                 <h4 style=
"border-bottom: 1px solid #FF5722;" class="title">Login Form</h4>
92             </div>
93             
94             <div
class="form-group" method="post" action="#">
95                 <label>Username</label>
96                 <input type=
"text" name="username" class="form-control" placeholder="Enter Username" autofocus>
97             </div>
98             
99             <div
class="form-group">
100                 <label>Password</label>
101                 <input type=
"password" name="password" class="form-control" placeholder="Enter your password">
102             </div>
103             
104             <!--<p><a style=
"color: #FF5722;" href="register.php">No account yet! Click Here to register</a></p>-->
105             
106             <input type=
"submit" name="submit" value="Login" class="btn btn-info btn-fill pull-right" style="background: #FF5722; border-color: #FF5722;" />
107             <div
class="clearfix"></div>
108             
109         </form>
110         
111     </div>
112     
113 </div>
114
115 </body>
116
117 </html>


Gõ tìm kiếm nhanh...